1. Field of the Invention
The present invention relates to a technique for decoding coded data that has been truncated to a fixed length.
2. Description of the Related Art
In recent years, higher resolution and a larger number of bits have been demanded in the field of image processing in order to increase image quality. Image quality improves the more information an image has, but storage volume, data transfer time and the like increase as a result of an image having a large amount of information. In such a case, normally images are encoded in order to reduce storage volume.
One of the encoding methods is compression using an orthogonal transform typified by the JPEG encoding scheme. This method is generally known for having a high coding efficiency and little distortion with respect to images having a strong correlation between neighboring pixels and large transform coefficients in low frequency areas, such as natural images.
Also, with an image processing apparatus, processes such as rotating image data and then printing them need to be performed at high speed in a memory with limited capacity. Therefore, encoding technique that allows images of arbitrary portions of the encoded data to be easily obtained, without decoding all of the encoded data, from the encoded data compressed by orthogonal transformation and subsequent coding. That is, encoding that involves fixed-length truncation of the code amount in predetermined pixel units (blocks), and decoding independence (nature of being decodable only with data truncated to a fixed length). Hereinafter, truncation of the code amount in the predetermined pixel units (blocks) to a fixed length will be simply called fixed-length truncation, and the code amount in the predetermined pixel units (blocks) will be called a fixed length.
With fixed-length truncation, in the case where encoded data does not fit within the fixed length, the encoded data is adjusted so as to fit within the fixed length by omitting encoded data (hereinafter, referred to as a cutting off process). For example, when the data of FIG. 2, which has been obtained by encoding image data (not shown) with the JPEG encoding scheme, is truncated to a fixed length, the encoded data is adjusted to fit within the fixed length by omitting data on the LSB side of the encoded data as shown in FIG. 3. The reason for omitting data on the LSB side is because the higher frequency component information exists in the LSB side, and there is considered to be little effect on image quality from shortening high frequency AC coefficient data compared with DC coefficient data or low frequency AC coefficient data. Note that with JPEG, data is encoded separately as code words that are obtained by performing 2-dimensional Huffman coding on group numbers indicating the run length of zero coefficients and the range of coefficients (bit number of additional bits) and as additional bits that represent coefficient values.
In the case of decoding encoded data that has undergone the cutting off process, in the related art, a combination of a code word and additional bits with missing bits due to the cutting off process is decoded as a code word indicating EOB. For example, in the case of decoding the encoded data shown in FIG. 2, the additional bits with missing bits and the code word corresponding to the additional bits are decoded after being substituted for a code word indicating EOB as shown in FIG. 12. With the above related art, high frequency AC coefficient data are thus cut off with little image degradation effect, but even so image degradation occurs due to the effect of the cutting off process. In particular, image degradation appears markedly with images that include large high frequency components such as edges. As a measure for dealing with the above problem, in Japanese Patent Laid Open No. 5-227431, for example, a method is proposed for improving image quality by performing edge detection on a decoded image, and performing predetermined image processing if an edge is detected. Also, in Japanese Patent Laid Open No. 2000-165877, a proposal has been made whereby the Huffman coding process is forcibly cut off once the block code amount exceeds a preset code amount, and EOBt is placed at the end of the encoded data of the block. With the method of Japanese Patent Laid Open No. 2000-165877, a compensation process is performed whereby the code word EOBt, added at the time of encoding and indicating that encoding was cut off, is detected at the time of decoding, and edge blur is recovered with respect to the detected block image.
However, with the method of improving image quality disclosed in Japanese Patent Laid Open No. 5-227431, the edge detection accuracy itself is not good, since edges are extracted from a decoded image whose image quality has been degraded due to the cutting off process. Thus, block distortion or mosquito noise near an edge due to the effect of the cutting off process may conversely become noticeable.
Also, with the method disclosed in Japanese Patent Laid Open No. 2000-165877, a Huffman code (EOBt) indicating that encoding was cut off needs to be added to the encoded data. Thus, the code amount to undergo cutting off must be determined by subtracting the cutoff code word EOBt. Further, in order to add the information required in the process of recovering edge blur, the code amount to undergo cutting off is further reduced, and block distortion or mosquito noise near an edge due to the effect of the cutting off process cannot be effectively reduced. Also, because the cutoff code word and information required in the edge recovery process are added, the cutting off process becomes complicated (the code amount to undergo cutting off cannot be ascertained until the code amount of information required in the edge recovery process is ascertained).